package com.mini.game.auth;

public class ThreadLocalUserContext {
    private static final ThreadLocal<Long> ID_HOLDER = new ThreadLocal<>();


    public static void bindUserId(long userId) {
        ID_HOLDER.set(userId);
    }


    public static void unbindUserId() {
        ID_HOLDER.remove();
    }

    public static long getUserId() {
        Long id = ID_HOLDER.get();
        return id == null ? 0 : id;
    }
}
